package com.moleq.models;

import com.moleq.db.DatabaseSchema;

public class Pinpad implements IDevModel {
	// pp_no integer NOT NULL,
	// pp_port integer NOT NULL,
	// pp_device_name varchar(30) NULL,
	// pp_timeout integer NULL,
	// pp_destip varchar(20) NULL,
	// pp_using varchar(1) NULL,
	// create_datetime varchar(14) NULL,
	// update_datetime varchar(14) NULL,
	// signature_fl varchar(1)
	// pp_destport integer NULL,
	// pp_con_type varchar(10) NULL,
	private int no;
	private int port;
	private String deviceName;
	private int timeout;
	private String destip;
	private String using;
	private String create_datetime;
	private String update_datetime;
	private String signature_fl;
	private int destport;
	private String con_type;

	public Pinpad() {
	}

	public Pinpad(int no, int port, String deviceName, int timeout,
			String destip, String using, String signature_fl,
			int destport,String con_type) {
		this.no = no;
		this.port = port;
		this.deviceName = deviceName;
		this.timeout = timeout;
		this.destip = destip;
		this.using = using;
		this.signature_fl = signature_fl;
		this.destport = destport;
		this.con_type = con_type;
	}
	
	public Pinpad(int no, int port, String deviceName, int timeout,
			String destip, String using,String create_datetime,
			String update_datetime, String signature_fl,
			int destport,String con_type) {
		this.no = no;
		this.port = port;
		this.deviceName = deviceName;
		this.timeout = timeout;
		this.destip = destip;
		this.using = using;
		this.create_datetime = create_datetime;
		this.update_datetime = update_datetime;
		this.signature_fl = signature_fl;
		this.destport = destport;
		this.con_type = con_type;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getDeviceName() {
		return deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

	public String getDestip() {
		return destip;
	}

	public void setDestip(String destip) {
		this.destip = destip;
	}

	public String getUsing() {
		return using;
	}

	public void setUsing(String using) {
		this.using = using;
	}

	public String getCreate_datetime() {
		return create_datetime;
	}

	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}

	public String getUpdate_datetime() {
		return update_datetime;
	}

	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}
	
	public String getSignature_fl() {
		return signature_fl;
	}

	public void setSignature_fl(String signature_fl) {
		this.signature_fl = signature_fl;
	}
	
	public int getDestport() {
		return destport;
	}

	public void setDestport(int destport) {
		this.destport = destport;
	}

	public String getCon_type() {
		return con_type;
	}

	public void setCon_type(String con_type) {
		this.con_type = con_type;
	}

	@Override
	public boolean isActive() {
		return getUsing().equals("Y");
	}

	@Override
	public String getDevice() {
		// TODO Auto-generated method stub
		return "Pinpad";
	}
	
	public String toMGData(String Action) {
		String Result = Action + "|"
				+ DatabaseSchema.ScannerSetting.SCHEMA_NAME + "|(" + getNo()
				+ "," + getPort() + "," + CheckNull(getDeviceName()) + ","
				+ getTimeout() + "," + CheckNull(getDestip()) + ","
				+ CheckNull(getUsing()) + "," + CheckNull(getCreate_datetime())
				+ "," + CheckNull(getUpdate_datetime()) + ","+ getDestport() + ","
				+ CheckNull(getCon_type()) + ")";
		return Result;
	}

	public String CheckNull(String value) {
		if (value == null) {
			return null;
		} else {
			return "'" + value + "'";
		}
	}
}
